package com.itspeedster.betterforeyes;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JSlider;

@SuppressWarnings("serial")
public class SettingView extends JFrame{

	JCheckBox	cbClose;
	JSlider		slOpacity;
	JButton		btSave;
	JButton		btCancel;
	
	JComboBox<String> cbDoTime = new JComboBox<String>(
			new String[]{"30 Phút", "1 Giờ","1 Giờ 30 Phút", "2 Giờ", "2 Giờ 30 Phút", "3 Giờ"});
	JComboBox<String> cbRelaxTime = new JComboBox<String>(
			new String[]{"30 Giây","1 Phút", "2 Phút", "3 Phút", "4 Phút", "5 Phút"});
	
	public SettingView(){
		super("Better For Eyes - Setting");
		setSize(400, 200);
		setLocationRelativeTo(null);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		
		initView();
	}
	
	public void initView(){
		setLayout(new GridLayout(5, 2, 5, 5));
		
		add(new JLabel("Thời gian làm việc"));
		add(cbDoTime);
		add(new JLabel("Thời gian nghỉ"));
		add(cbRelaxTime);
		add(new JLabel("Cho phép đóng"));
		add(cbClose = new JCheckBox());
		
		
		add(new JLabel("Độ che khuất"));
		add(slOpacity = new JSlider(0, 100, 50));
		
		add(btSave =  new JButton("Lưu"));
		add(btCancel =  new JButton("Hủy bỏ"));
		
		btSave.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				int doTimeIndex = cbDoTime.getSelectedIndex();
				int doTime = doTimeIndex * 30 + 30;
				AppLauncher.config.doingTime = doTime * 1000;
			}
		});
	}
}
